package Manager;

import Entity.DurationDetails;
import java.util.ArrayList;
import java.util.Date;

/**
 *
 * @author CONG
 */
public class DurationDetailsManager {

    private ArrayList<DurationDetails> listDurDe;

    public DurationDetailsManager() {
        listDurDe = new ArrayList<DurationDetails>();
    }

    public void getDurationDetailsList(ArrayList<DurationDetails> dur) {
        listDurDe.clear();
        listDurDe.addAll(dur);
    }

    public int getSize() {
        return listDurDe.size();
    }

    public DurationDetails getDurDe(int index) {
        return listDurDe.get(index);
    }
    public void updateDurationHistory(DurationDetails durde){
        for (int i = 0; i < listDurDe.size(); i++) {
            int accountLoancode=listDurDe.get(i).getAccountLoanCode();
            Date dateDue=listDurDe.get(i).getDateDue();
            if(accountLoancode==durde.getAccountLoanCode() && dateDue==durde.getDateDue()){
                listDurDe.set(i, durde);
            }
        }
    }
    public void addDurationDetails(DurationDetails durde){
        //listDurDe.clear();
        listDurDe.add(durde);
    }
    public void removeDurationDetails(ArrayList<DurationDetails> durde){
        listDurDe.removeAll(durde);
    }
}
